<template>
	<m-layout title="下级分公司列表">
		<view class="content">
			<m-block gap="30" spa="0 0 20" v-for="(item,index) in listArr" class="listBox" :key="index">
			<!-- 	<text class="fs24 tag tag22">公司发起人</text> -->
				<view class="flex-between">
					<view class="flex-column">
						<view class="flex">
							<m-icon size="36" spa="0 10 0 0" color="#887dff" type="icon-gongsimingcheng"  />
							<text class="otp2 fs30 fw-600 " style="max-width: 420rpx;">{{item.titel}}</text>
						</view>
						<view class="fs24 mt-8" v-html="item.content"></view>
					</view>
					<m-image2 :src="item.picurl.split(',')[0]" size="140" radius="12" />
				</view>
				<view class="fs24 mt-8 fw-600">
					<text>发起用户：</text>
					<text>{{item.username}}</text>
				</view>
				<view class="fs24 mt-8 fw-600">
					<text>公司法人姓名：</text>
					<text>{{item.truename}}</text>
				</view>
			<!-- 	<view class="fs24 mt-8 fw-600">
					<text>邀请码：</text>
					<text>{{item.invcode}}</text>
				</view> -->
				<view class="fs24 mt-8 fw-600">
					<text>联系方式：</text>
					<text>{{item.phone}}</text>
				</view>
				<!-- <view class="fs24 mt-8 fw-600">
					<text>团队代理商人数：</text>
					<text>{{item.teamdls}}</text>
				</view> -->
				<!-- <view class="fs24 mt-8 fw-600">
					<text>团队业绩：</text>
					<text>{{item.teamamount}}</text>
				</view> -->
			</m-block>
			<m-empty :loading="isLoading" v-if="listArr.length<=0" spa="120 0" title="未查询到数据" size="300" icon='empty' />
		</view>
	</m-layout>
</template>

<script>
	import { mapState, mapActions } from 'vuex';
	import { myteamCompy } from '@/api/Users.js';
	export default {
		name: 'myteamCompy',
		data() {
			return {
				pageIndex: 1, // 当前页数
				pageSize: 10,
				pageCount: 1, // 列表总页数（用于加载更多）
				listArr: [], // 主列表
				isLoading: false,
				btnLoading: false,
				compyid:0,
			}
		},
		computed: {
			...mapState({
			}),
		},
		watch: {
		},
		onLoad({compyid}) {
			this.compyid=compyid
		},
		onShow() {
			this.initData();
		},
		onPullDownRefresh() {
			this.initData();
		},
		onReachBottom() {
			if (this.pageIndex < this.pageCount) {
				this.pageIndex += 1;
				this.getList();
			}
		},
		methods: {
			///////////////////////////////////// 初始化 ////////////////////////////////////////
			initData() {
				this.isEditor = false;
				this.pageIndex = 1;
				this.pageSize = 10;
				this.pageCount = 1;
				this.listArr = [];
				this.getList();
			},
			///////////////////////////////////// 网络请求 ////////////////////////////////////////
			// 获取主列表
			async getList() {
				if (this.pageIndex > this.pageCount) {
					return
				}
				this.isLoading = true;
				const { data } = await myteamCompy({
					compyid:this.compyid,
					// pageSize: this.pageSize,
					// pageIndex: this.pageIndex,
				});
				this.isLoading = false;
				this.listArr = data;
				// this.pageCount = pageCount;
				// if (this.pageIndex <= 1) {
				// 	this.listArr = data;
				// } else {
				// 	this.listArr = [...this.listArr, ...data];
				// }
				// this.pageIndex++;
				uni.stopPullDownRefresh();
			},
			setAddressCloseFn() {
				this.$store.commit('address/SET_HAVESELECTEN', false)
				this.setAddressShow = false;
				this.btnLoading = false;
			},
			onPullDownRefresh() {
				this.initData();
			},
			onReachBottom() {
				// this.getList();
				console.log('触底了');
			}
		}
	}
</script>

<style lang="scss">
	.content {
		padding: 24rpx;
	}

	.listBox {
		position: relative;
	}

	.tag {
		position: absolute;
		right: 0rpx;
		top: 0rpx;
		padding: 12rpx 32rpx;
		color: #FFFFFF;
		background-color: #786BFF;
		font-size: 21rpx;
		border-radius: 0rpx 20rpx 0rpx 24rpx;
		position: absolute;
	}

	.tag22 {
		background-color: #826a4a;
	}
</style>